package wnhz.com.business.freeshop.activity.fourthfree;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import wnhz.com.business.R;
import wnhz.com.business.base.BaseActivity;
import wnhz.com.business.base.BaseRVAdapter;
import wnhz.com.business.base.BaseViewHolder;
import wnhz.com.business.groupshop.bean.MessageBean;
import wnhz.com.business.impl.ActionBarClickListener;
import wnhz.com.business.view.TranslucentActionBar;
import wnhz.com.business.view.TranslucentActionBarW;

/**
 * 消息界面
 */
public class MessageActivity extends BaseActivity implements ActionBarClickListener {

    @BindView(R.id.actionbar)
    TranslucentActionBarW actionbar;
    @BindView(R.id.recycler_message)
    RecyclerView recyclerMessage;
    @BindView(R.id.ll_tongzhi)
    LinearLayout llTongzhi;
    @BindView(R.id.ll_wuliu)
    LinearLayout llWuliu;
    @BindView(R.id.ll_pinglun)
    LinearLayout llPinglun;

    private List<MessageBean> data = new ArrayList<>();

    public static Intent createIntent(Context context) {
        Intent intent = new Intent(context, MessageActivity.class);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message_f);
        ButterKnife.bind(this);
        actionbar.setData("消息", R.drawable.ic_left_back, null, 0, null, 0, this);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            actionbar.setStatusBarHeight(getStatusBarHeight());
        }
        initview();
        setRecyclerMessage();
    }

    private void initview() {
        data.clear();
        data.add(new MessageBean("刘勇女装专营店", "好的,亲 我们会尽快发货的", "2017.03.06"));
        data.add(new MessageBean("李涛女装专营店", "亲,您的宝贝已经签收了, 给我们好评吧!", "2017.02.13"));
        data.add(new MessageBean("甜甜家居小广场", "好的,亲 我们会尽快发货的亲 我们会尽快发货的", "2017.09.13"));
        recyclerMessage.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    }

    private void setRecyclerMessage() {
        recyclerMessage.setAdapter(new BaseRVAdapter(this, data) {
            @Override
            public int getLayoutId(int viewType) {
                return R.layout.item_message;
            }

            @Override
            public void onBind(BaseViewHolder holder, int position) {
                holder.getTextView(R.id.tv_titles).setText(data.get(position).getTitle());
                holder.getTextView(R.id.tv_times).setText(data.get(position).getDate());
                holder.getTextView(R.id.tv_text).setText(data.get(position).getText());
            }

        });
    }

    @Override
    public void onLeftClick() {
        finish();
    }

    @Override
    public void onRightClick() {

    }

    @Override
    public void onEditTextClick() {

    }

    @OnClick({R.id.ll_tongzhi, R.id.ll_wuliu, R.id.ll_pinglun})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            //通知
            case R.id.ll_tongzhi:
                    startActivity(InformActivity.createIntent(this));
                break;
            //物流
            case R.id.ll_wuliu:
                startActivity(LogisticsActivity.createIntent(this,null,"1"));
                break;
            //评论
            case R.id.ll_pinglun:
                break;
        }
    }
}
